package com.zd.file.brower.vo;

import java.io.File;

public class FileVo {
    /** 文件名 */
    private String name;
    /** 是否是文件夹 */
    private boolean directory;
    /** 扩展名 */
    private String extension;

    public FileVo(File f) {
        this.name = f.getName();
        this.directory = f.isDirectory();
        if (this.directory) {
            extension = "..";
        }else if(name.indexOf(".") != -1 && !name.endsWith(".")){
            this.extension = name.substring(name.lastIndexOf(".")+1);
        }else {
            this.extension = "";
        }
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isDirectory() {
        return directory;
    }

    public void setDirectory(boolean directory) {
        this.directory = directory;
    }

    private void setExtension(String extension) {
        this.extension = extension;
    }

    public String getExtension(){
        return extension;
    }
}
